package com.the_ring.behavior.interpreter;

/**
 * @author: t22306139
 * @date: 2023/12/1  15:43
 */
public class MainTest {

    // 规则：Robert 和 John 是男性
    public static Expression getMaleExpression() {
        Expression robert = new TerminalExpression("Robert");
        Expression john = new TerminalExpression("John");
        return new OrExpression(robert, john);
    }

    // 规则：Julie 是一个已婚女性
    public static Expression getMarriedWomanExpression() {
        Expression julie = new TerminalExpression("Julie");
        Expression married = new TerminalExpression("Married");
        return new AndExpression(julie, married);
    }

    public static void main(String[] args) {
        Expression isMale = getMaleExpression();
        Expression isMarriedWoman = getMarriedWomanExpression();

        System.out.println("John 是男性吗？ " + isMale.interpret("John"));
        System.out.println("Julie 是已婚女性吗？ " + isMarriedWoman.interpret("Married Julie"));
    }
}
